﻿using EntityModels.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityModels.DbContexts
{
    /// <summary>
    /// 构造函数和只读属性
    /// </summary>
    public class ConstructorDbContext : DbContext
    {
        public DbSet<ConstructorEntity> ConstructorEntities => Set<ConstructorEntity>();

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<ConstructorEntity>()
                // 配置主键到私有字段
                .HasKey("_id");

            modelBuilder.Entity<ConstructorEntity>()
                // 配置映射只读属性
                .Property(c => c.Number);

        }

    }
}
